package com.calendar;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

/**
 * @Author WaveHi
 * @Date 11/8/2021 下午 3:03
 * @Version 1.0
 * @Contact HJBWaveHi@163.com
 * @Description
 */
public class Exce1 {

    public static void main(String[] args) {

        //获取时间
        SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        Date d1 = new Date();
        try {
            d1 = sdf1.parse("2017-11-12 12:23:43");
        } catch (ParseException e) {
            e.printStackTrace();
        }

        //获取Calendar类的对象操作时间
        Calendar is1 = Calendar.getInstance();
        is1.setTime(d1);

        //获取结束时间
        is1.set(Calendar.HOUR,23);
        is1.set(Calendar.MINUTE,59);
        is1.set(Calendar.SECOND,59);
        System.out.println("endTime = " + sdf1.format(is1.getTime()));


        //通过结束时间计算开始时间
        is1.add(Calendar.SECOND,1);
        System.out.println("startTime = " + sdf1.format(is1.getTime()));


    }

}
